import pygame
from pygame.locals import *
from costants import *
from ranking import *

pygame.font.init()

try: font=pygame.font.Font(FONT,FONT_DIM2)
except IOError: font=pygame.font.Font(ALTERNATIVE_FONT,FONT_DIM2)

bg_image=pygame.image.load(BACKGROUND_IMAGE)
######################################################################
######################################################################
class Judge:
	def __init__(self,screen):
		self.screen=screen
		self.old_status=0
		
	def rank(self,global_status,empty_lines,deleted_lines):
		if empty_lines<=5:
			Smiley(BOMB,"READY TO BLOW!!",self.screen)
		else:
			if self.old_status< global_status:
				self.wrong()
				self.old_status=global_status
			else:
				if deleted_lines==0: 
					result=empty_lines-global_status
					if result >= 13:
						Smiley(GOOD,"GOOD...GO ON!!!",self.screen)
					elif result >=5 and result<13:
						Smiley(CAREFUL," KEEP FOCUSED!!",self.screen)
					elif result>=-5 and result <5:
						Smiley(BAD," WHAT'S WRONG? ",self.screen)
					else:
						Smiley(DISASTER,"YOU'RE HOPELESS",self.screen)
				elif deleted_lines<4:
					Smiley(WELL_DONE,"YEAH! WELL DONE!",self.screen)
				else:
					Smiley(PROF,"YOU'RE A MASTER!",self.screen)

	def wrong(self):
		Smiley(STUPID,"WRONG CHOICE...",self.screen)
######################################################################
class Smiley:
	def __init__(self,image,sentence,screen):
		self.sentence=font.render(sentence, True,ROYALBLUE)
		self.image=pygame.image.load(image).convert_alpha()
		bg_image.convert()
		screen.blit(bg_image,EMOTIC_RECT,EMOTIC_RECT)
		screen.blit(self.image,self.image.get_rect(center=EMOTIC_POS))
		screen.blit(self.sentence,self.sentence.get_rect(center=EMOTICW_POS))
		pygame.display.update()
######################################################################
######################################################################

